/*
 * @Description: 自定义tabbar
 * @Author: rendc
 * @Date: 2022-12-18 09:27:40
 * @LastEditors: rendc
 * @LastEditTime: 2022-12-20 10:18:01
 */
// pages/custom-tab-bar/index.js
Component({
  data: {
    active: 1,
    list: [
      {
        pagePath: "/pages/index/index",
        icon: "home-o",
        text: "首页",
      },
      {
        pagePath: "/pages/home/home",
        icon: "completed",
        text: "分类",
      },
      {
        pagePath: "/pages/logs/logs",
        icon: "friends-o",
        text: "日志",
      },
      {
        pagePath: "/pages/my/my",
        icon: "setting-o",
        text: "我的",
      },
    ],
  },
  methods: {
    onChange (event) {
      // event.detail 的值为当前选中项的索引
      this.setData({ active: event.detail });
      // 跳转到对应的页面
      let url = this.data.list[event.detail].pagePath;
      wx.switchTab({
        url
      });
    },
    init (index) {
      // 处理 active
      this.setData({ active: index });
    }
  },
})